package stv5.abstracted;

import stv5.Request;
import stv5.Response;

/**
 * Abstraction layer for HTTP connections
 * 
 * @author dhleong
 *
 */
public interface Connection {
	
	/**
	 * Close the connection
	 */
	public void close();
	
	/**
	 * Flush the data down the tube
	 */
	public void flush();
	
	/**
	 * Is this a local (loopback) connection?
	 * 
	 * @return
	 */
	public boolean isLocal();

	/**
	 * Reads the Request that should be sent on the connection
	 * @return the Request, or null on error
	 */
	public Request read();
	
	/**
	 * Send our response down the line
	 * 
	 * @param response
	 * @return True if successfully sent, else false
	 */
	public boolean send(Response response);
}
